IF EXISTS (SELECT * FROM sysobjects WHERE name = 'GetMachineIdForMachineName' AND type IN ('FN','IF','TF'))
     DROP FUNCTION dbo.GetMachineIdForMachineName
GO

CREATE FUNCTION dbo.GetMachineIdForMachineName
     ( @MachineName varchar(255) )
RETURNS int
AS
/*
 *
 * GetMachineIdForMachineName
 *
 * Purpose:      
 *
 * Inputs:       
 *
 * Assumes:      
 *
 * Effects:      
 *
 * Returns:      
 *
 * Calling
 * Application:  
 *
 * Note(s):      
 *
 * Author(s):    NOVA Concepts Ltd.
 *
 * Change Log:   Initial Release, 09/29/2011, 1.00.0000
 *
 */
BEGIN
     DECLARE @ReturnValue int

     SELECT @ReturnValue = MachineId
     FROM   dbo.Machine 
     WHERE  MachineName   = @MachineName
     OR     FQMachineName = @MachineName

     RETURN @ReturnValue
END
GO
